package com.sg.service.biz.pbff.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.sg.common.exception.Assert;
import com.sg.common.util.RedisUtil;
import com.sg.dto.biz.pbff.req.*;
import com.sg.dto.biz.pbff.res.*;
import com.sg.service.biz.pbff.RoleService;
import com.sg.service.biz.pbff.nb.NbRole;
import com.wicket.okrframework.integration.*;
import com.wicket.okrframework.integration.dto.*;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.stream.Collectors;

/**
 * @author ：
 * @version 1.0
 * @date ：
 */
@Service
public class RoleServiceImpl implements RoleService {

    @Resource
    com.sg.service.biz.framework.RoleService fwBaseRoleClient;
    @Resource
    com.sg.service.biz.framework.InductionRecordService fwBaseInductionRecordClient;
    @Resource
    com.sg.service.biz.framework.MemberService fwBaseMemberClient;
    @Resource
    com.sg.service.biz.framework.DivineDataService fwBaseDivineDataClient;
    @Resource
    NbRole nbRole;
    @Resource
    private RedisUtil redisUtil;
    @Resource
    com.sg.service.biz.framework.AppSceneService fwBaseAppSceneClient;

    /**
     * B1-2查询角色列表（平台）[542]
     * gen by moon at 8/15/2022, 10:27:37 PM
     */
    @Trace(operationName = "B1-2查询角色列表（平台）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryRoleListRespDto queryRoleList(BffQueryRoleListReqDto reqDto) {


        QueryRoleListRespDto queryRoleListRespDto_1 = null;
        BatchQueryInductionRecordListComRespDto batchQueryInductionRecordListComRespDto_1 = null;
//步骤0: D1-2查询角色列表 - queryRoleList
        QueryRoleListRespDto queryRoleListRespDto = null;
        QueryRoleListReqDto queryRoleListReqDto = new QueryRoleListReqDto();
        if (reqDto != null) {
            queryRoleListReqDto.setRoleType(reqDto.getRoleType());//sourceId:26169_1
            queryRoleListReqDto.setIsIdentity(reqDto.getIsIdentity());//sourceId:26171_1
            queryRoleListReqDto.setAutomaticCreation(reqDto.getAutomaticCreation());//sourceId:26172_1
            queryRoleListReqDto.setPlatformData(reqDto.getPlatformData());//sourceId:26173_1
            queryRoleListReqDto.setIsArchive(reqDto.getIsArchive());//sourceId:26176_1
        }

        /*D1-2查询角色列表[543]   */
        Assert.isNull(queryRoleListReqDto.getIsArchive(), "B1-2查询角色列表（平台）-D1-2查询角色列表-是否存档不能为空", false);
        queryRoleListRespDto = fwBaseRoleClient.queryRoleList(queryRoleListReqDto).getData();

        queryRoleListRespDto_1 = queryRoleListRespDto;

//步骤1: D1-3批量查询就职记录列表（公共） - batchQueryInductionRecordListCom
        BatchQueryInductionRecordListComRespDto batchQueryInductionRecordListComRespDto = null;
        if (queryRoleListRespDto != null) {
            BatchQueryInductionRecordListComReqDto batchQueryInductionRecordListComReqDto = new BatchQueryInductionRecordListComReqDto();
            if (queryRoleListRespDto != null) {
                batchQueryInductionRecordListComReqDto.setPerOrgInductionRecordList(queryRoleListRespDto.getRoleList().stream().map(item -> item.getOperationInductionId())
                        .collect(Collectors.toList()));//sourceId:26180_1
            }

            /*D1-3批量查询就职记录列表（公共）[602]   */

            batchQueryInductionRecordListComRespDto = fwBaseInductionRecordClient.batchQueryInductionRecordListCom(batchQueryInductionRecordListComReqDto).getData();

            batchQueryInductionRecordListComRespDto_1 = batchQueryInductionRecordListComRespDto;
        }

        BffQueryRoleListRespDto retData = new BffQueryRoleListRespDto();
        //数据集融合
        if (queryRoleListRespDto_1 != null && !CollectionUtil.isEmpty(queryRoleListRespDto_1.getRoleList())) {
            for (FrameworkSceneRoleDto frameworkSceneRoleDto : queryRoleListRespDto_1.getRoleList()) {
                BffFrameworkSceneRoleDto retElm = new BffFrameworkSceneRoleDto();
                if (queryRoleListRespDto_1 != null) {
                    retElm.setRoleId(frameworkSceneRoleDto.getRoleId());//sourceId:10663_2
                    retElm.setRoleName(frameworkSceneRoleDto.getRoleName());//sourceId:10665_2
                    retElm.setRoleCode(frameworkSceneRoleDto.getRoleCode());//sourceId:10664_2
                    retElm.setSubjectLifeCycle(frameworkSceneRoleDto.getSubjectLifeCycle());//sourceId:10674_2
                    retElm.setOperationInductionId(frameworkSceneRoleDto.getOperationInductionId());//sourceId:10676_2
                    retElm.setOperateTime(frameworkSceneRoleDto.getOperateTime());//sourceId:10677_2
                }
                retData.getRoleList().add(retElm);
                if (batchQueryInductionRecordListComRespDto_1 != null) {
                    for (PerOrgInductionRecordDto perOrgInductionRecordDto : batchQueryInductionRecordListComRespDto_1.getPerOrgInductionRecordList()) {
                        if (perOrgInductionRecordDto.getInductionRecordId().equals(frameworkSceneRoleDto.getOperationInductionId())) {
                            if (batchQueryInductionRecordListComRespDto_1 != null) {
                                retElm.setUserId(perOrgInductionRecordDto.getUserId());//sourceId:38726_2
                                retElm.setUserFace(perOrgInductionRecordDto.getUserFace());//sourceId:38729_2
                                retElm.setIdCardName(perOrgInductionRecordDto.getIdCardName());//sourceId:38727_2
                                retElm.setNickName(perOrgInductionRecordDto.getNickName());//sourceId:38728_2
                            }
                        }
                    }
                }

            }
        }//sourceId:26193_1


        retData.setPageNum(queryRoleListRespDto.getPageNum());
        retData.setPageSize(queryRoleListRespDto.getPageSize());
        retData.setTotal(queryRoleListRespDto.getTotalNum());
        retData.setIsLastPage((Math.ceil(Double.valueOf(queryRoleListRespDto.getTotalNum()) / Double.valueOf(queryRoleListRespDto.getPageSize()))) <= retData.getPageNum());


        return retData;
    }

    /**
     * B1-2存档角色（平台）[1557]
     * gen by moon at 8/10/2022, 3:43:41 AM
     */
    @Trace(operationName = "B1-2存档角色（平台）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffArchiveRoleRespDto archiveRole(BffArchiveRoleReqDto reqDto) {


        //步骤0: D1-2存档角色 - archiveRole
        ArchiveRoleRespDto archiveRoleRespDto = null;
        ArchiveRoleReqDto archiveRoleReqDto = new ArchiveRoleReqDto();
        if (reqDto != null) {
            archiveRoleReqDto.setRoleId(reqDto.getRoleId());//sourceId:44734_1
        }

        /*D1-2存档角色[1558]   */
        Assert.isNull(archiveRoleReqDto.getRoleId(), "B1-2存档角色（平台）-D1-2存档角色-角色ID不能为空", false);
        archiveRoleRespDto = fwBaseRoleClient.archiveRole(archiveRoleReqDto).getData();


//步骤1: D1-2查询角色人员列表 - queryRoleRelList
        QueryRoleRelListRespDto queryRoleRelListRespDto = null;
        QueryRoleRelListReqDto queryRoleRelListReqDto = new QueryRoleRelListReqDto();
        if (reqDto != null) {
            queryRoleRelListReqDto.setRoleId(reqDto.getRoleId());//sourceId:56474_1
        }

        /*D1-2查询角色人员列表[1134]   */
        Assert.isNull(queryRoleRelListReqDto.getRoleId(), "B1-2存档角色（平台）-D1-2查询角色人员列表-角色ID不能为空", false);
        queryRoleRelListRespDto = fwBaseMemberClient.queryRoleRelList(queryRoleRelListReqDto).getData();


//步骤2: Redis批量清空用户信息 - batchClearUserInfoFromRedis
        //ModelCode: batchClearUserInfoFromRedis
        BatchClearUserInfoFromRedisRespDto batchClearUserInfoFromRedisRes = null;
        if (queryRoleRelListRespDto != null) {
            BatchClearUserInfoFromRedisReqDto batchClearUserInfoFromRedisReq = new BatchClearUserInfoFromRedisReqDto();
            if (queryRoleRelListRespDto != null) {
                batchClearUserInfoFromRedisReq.setBeginMemberList(queryRoleRelListRespDto.getRoleRelList().stream().map(item -> item.getRoleMemberId())
                        .collect(Collectors.toList()));//sourceId:51526_1
            }

            /*Redis批量清空用户信息[1713]  入参身份ID数据集，清除用户就职信息缓存 */

            batchClearUserInfoFromRedisRes = nbRole.batchClearUserInfoFromRedis(batchClearUserInfoFromRedisReq);


        }

        BffArchiveRoleRespDto retData = new BffArchiveRoleRespDto();


        return retData;
    }

    /**
     * B1-2修改角色（平台）[549]
     * gen by moon at 8/10/2022, 3:40:24 AM
     */
    @Trace(operationName = "B1-2修改角色（平台）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffUpdateRoleRespDto updateRole(BffUpdateRoleReqDto reqDto) {


        //步骤0: D1-2修改角色 - updateRole
        UpdateRoleRespDto updateRoleRespDto = null;
        UpdateRoleReqDto updateRoleReqDto = new UpdateRoleReqDto();
        if (reqDto != null) {
            updateRoleReqDto.setRoleId(reqDto.getRoleId());//sourceId:26274_1
            updateRoleReqDto.setRoleName(reqDto.getRoleName());//sourceId:26276_1
            updateRoleReqDto.setRoleRemark(reqDto.getRoleRemark());//sourceId:26277_1
            updateRoleReqDto.setRoleLogo(reqDto.getRoleLogo());//sourceId:33633_1
            updateRoleReqDto.setRoleType(reqDto.getRoleType());//sourceId:26278_1
            updateRoleReqDto.setIsIdentity(reqDto.getIsIdentity());//sourceId:26281_1
            updateRoleReqDto.setHostTypeId(reqDto.getHostTypeId());//sourceId:26285_1
            updateRoleReqDto.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//sourceId:26284_1
        }

        /*D1-2修改角色[548]   */
        Assert.isNull(updateRoleReqDto.getRoleId(), "B1-2修改角色（平台）-D1-2修改角色-角色ID不能为空", false);
        updateRoleRespDto = fwBaseRoleClient.updateRole(updateRoleReqDto).getData();


        BffUpdateRoleRespDto retData = new BffUpdateRoleRespDto();


        return retData;
    }

    /**
     * B1-2新增角色（平台）[547]
     * gen by moon at 8/17/2022, 8:03:51 PM
     */
    @Trace(operationName = "B1-2新增角色（平台）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffAddRoleRespDto addRole(BffAddRoleReqDto reqDto) {


        AddRoleRespDto addRoleRespDto_1 = null;
//步骤0: D1-2新增角色 - addRole
        AddRoleRespDto addRoleRespDto = null;
        AddRoleReqDto addRoleReqDto = new AddRoleReqDto();
        addRoleReqDto.setAutomaticCreation("TRUE");//sourceId:26214_1
        addRoleReqDto.setPlatformData("TRUE");//sourceId:26215_1
        if (reqDto != null) {
            addRoleReqDto.setRoleCode(reqDto.getRoleCode());//sourceId:54448_1
            addRoleReqDto.setRoleName(reqDto.getRoleName());//sourceId:54449_1
            addRoleReqDto.setRoleRemark(reqDto.getRoleRemark());//sourceId:26209_1
            addRoleReqDto.setRoleLogo(reqDto.getRoleLogo());//sourceId:33628_1
            addRoleReqDto.setRoleType(reqDto.getRoleType());//sourceId:26211_1
            addRoleReqDto.setHostTypeId(reqDto.getHostTypeId());//sourceId:26216_1
            addRoleReqDto.setIsIdentity(reqDto.getIsIdentity());//sourceId:26213_1
            addRoleReqDto.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//sourceId:27434_1
        }

        /*D1-2新增角色[546]   */
        Assert.isNull(addRoleReqDto.getRoleCode(), "B1-2新增角色（平台）-D1-2新增角色-角色标识不能为空", false);
        Assert.isNull(addRoleReqDto.getRoleName(), "B1-2新增角色（平台）-D1-2新增角色-角色名称不能为空", false);
        Assert.isNull(addRoleReqDto.getRoleType(), "B1-2新增角色（平台）-D1-2新增角色-角色类型不能为空", false);
        Assert.isNull(addRoleReqDto.getHostTypeId(), "B1-2新增角色（平台）-D1-2新增角色-宿主类型ID不能为空", false);
        Assert.isNull(addRoleReqDto.getIsIdentity(), "B1-2新增角色（平台）-D1-2新增角色-是否身份角色不能为空", false);
        Assert.isNull(addRoleReqDto.getAutomaticCreation(), "B1-2新增角色（平台）-D1-2新增角色-是否手动创建不能为空", false);
        Assert.isNull(addRoleReqDto.getPlatformData(), "B1-2新增角色（平台）-D1-2新增角色-是否平台数据不能为空", false);
        Assert.isNull(addRoleReqDto.getSubjectLifeCycle(), "B1-2新增角色（平台）-D1-2新增角色-主体生命周期不能为空", false);
        addRoleRespDto = fwBaseRoleClient.addRole(addRoleReqDto).getData();

        addRoleRespDto_1 = addRoleRespDto;

        BffAddRoleRespDto retData = new BffAddRoleRespDto();
        if (addRoleRespDto_1 != null) {
            retData.setRoleId(addRoleRespDto_1.getRoleId());//sourceId:26228_1
        }


        return retData;
    }

    /**
     * B1-2查询角色详情（平台）[545]
     * gen by moon at 8/19/2022, 1:29:00 PM
     */
    @Trace(operationName = "B1-2查询角色详情（平台）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryRoleDetailRespDto queryRoleDetail(BffQueryRoleDetailReqDto reqDto) {


        QueryRoleDetailRespDto queryRoleDetailRespDto_1 = null;
        QueryInductionRecordInfoDetailComRespDto queryInductionRecordInfoDetailComRespDto_1 = null;
//步骤0: D1-2查询角色详情 - queryRoleDetail
        QueryRoleDetailRespDto queryRoleDetailRespDto = null;
        QueryRoleDetailReqDto queryRoleDetailReqDto = new QueryRoleDetailReqDto();
        if (reqDto != null) {
            queryRoleDetailReqDto.setRoleId(reqDto.getRoleId());//sourceId:25496_1
        }

        /*D1-2查询角色详情[1163]   */

        queryRoleDetailRespDto = fwBaseRoleClient.queryRoleDetail(queryRoleDetailReqDto).getData();

        queryRoleDetailRespDto_1 = queryRoleDetailRespDto;

//步骤1: D1-3查询个人就职记录信息详情（公共） - queryInductionRecordInfoDetailCom
        QueryInductionRecordInfoDetailComRespDto queryInductionRecordInfoDetailComRespDto = null;
        if (queryRoleDetailRespDto != null) {
            QueryInductionRecordInfoDetailComReqDto queryInductionRecordInfoDetailComReqDto = new QueryInductionRecordInfoDetailComReqDto();
            if (queryRoleDetailRespDto != null) {
                queryInductionRecordInfoDetailComReqDto.setInductionRecordId(queryRoleDetailRespDto.getOperationInductionId());//sourceId:25823_1
            }

            /*D1-3查询个人就职记录信息详情（公共）[715]   */
            Assert.isNull(queryInductionRecordInfoDetailComReqDto.getInductionRecordId(), "B1-2查询角色详情（平台）-D1-3查询个人就职记录信息详情（公共）-就职记录ID不能为空", false);
            queryInductionRecordInfoDetailComRespDto = fwBaseInductionRecordClient.queryInductionRecordInfoDetailCom(queryInductionRecordInfoDetailComReqDto).getData();

            queryInductionRecordInfoDetailComRespDto_1 = queryInductionRecordInfoDetailComRespDto;
        }

        BffQueryRoleDetailRespDto retData = new BffQueryRoleDetailRespDto();
        if (queryRoleDetailRespDto_1 != null) {
            retData.setRoleId(queryRoleDetailRespDto_1.getRoleId());//sourceId:25754_1
            retData.setRoleCode(queryRoleDetailRespDto_1.getRoleCode());//sourceId:25755_1
            retData.setRoleName(queryRoleDetailRespDto_1.getRoleName());//sourceId:25756_1
            retData.setRoleRemark(queryRoleDetailRespDto_1.getRoleRemark());//sourceId:25757_1
            retData.setRoleLogo(queryRoleDetailRespDto_1.getRoleLogo());//sourceId:25758_1
            retData.setRoleType(queryRoleDetailRespDto_1.getRoleType());//sourceId:25759_1
            retData.setIsIdentity(queryRoleDetailRespDto_1.getIsIdentity());//sourceId:25761_1
            retData.setAutomaticCreation(queryRoleDetailRespDto_1.getAutomaticCreation());//sourceId:25762_1
            retData.setTempFreezeStatus(queryRoleDetailRespDto_1.getTempFreezeStatus());//sourceId:34330_1
            retData.setPlatformData(queryRoleDetailRespDto_1.getPlatformData());//sourceId:25763_1
            retData.setHostTypeId(queryRoleDetailRespDto_1.getHostTypeId());//sourceId:241565_1
            retData.setHostTypeName(queryRoleDetailRespDto_1.getHostTypeName());//sourceId:33623_1
            retData.setSubjectLifeCycle(queryRoleDetailRespDto_1.getSubjectLifeCycle());//sourceId:25765_1
            retData.setOperationInductionId(queryRoleDetailRespDto_1.getOperationInductionId());//sourceId:25767_1
            retData.setOperateTime(queryRoleDetailRespDto_1.getOperateTime());//sourceId:25768_1
        }
        if (queryInductionRecordInfoDetailComRespDto_1 != null) {
            retData.setUserId(queryInductionRecordInfoDetailComRespDto_1.getUserId());//sourceId:33618_1
            retData.setUserFace(queryInductionRecordInfoDetailComRespDto_1.getUserFace());//sourceId:25833_1
            retData.setIdCardName(queryInductionRecordInfoDetailComRespDto_1.getIdCardName());//sourceId:25831_1
            retData.setNickName(queryInductionRecordInfoDetailComRespDto_1.getNickName());//sourceId:25832_1
        }


        return retData;
    }

    /**
     * B1-2查询角色推荐列表(管理)[5052]
     * gen by moon at 11/3/2022, 12:40:29 PM
     */
    @Trace(operationName = "B1-2查询角色推荐列表(管理)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryRoleRecommendListRespDto queryRoleRecommendList(BffQueryRoleRecommendListReqDto reqDto) {


        QueryRoleRecommendListRespDto queryRoleRecommendListRespDto_1 = null;
        BatchQueryInductionRecordComRespDto batchQueryInductionRecordComRespDto_1 = null;
//步骤0: D1-2查询角色推荐列表 - queryRoleRecommendList
        QueryRoleRecommendListRespDto queryRoleRecommendListRespDto = null;
        QueryRoleRecommendListReqDto queryRoleRecommendListReqDto = new QueryRoleRecommendListReqDto();
        if (reqDto != null) {
            queryRoleRecommendListReqDto.setRoleType(reqDto.getRoleType());//SimpleFieldAssign//sourceId:407456_1
            queryRoleRecommendListReqDto.setAutomaticCreation(reqDto.getAutomaticCreation());//SimpleFieldAssign//sourceId:407457_1
            queryRoleRecommendListReqDto.setPlatformData(reqDto.getPlatformData());//SimpleFieldAssign//sourceId:407458_1
            queryRoleRecommendListReqDto.setIsRecommend(reqDto.getIsRecommend());//SimpleFieldAssign//sourceId:407459_1
        }

        /*D1-2查询角色推荐列表[5040]   */
        Assert.isNull(queryRoleRecommendListReqDto.getIsRecommend(), "B1-2查询角色推荐列表(管理)-D1-2查询角色推荐列表-是否推荐不能为空", false);
        queryRoleRecommendListRespDto = fwBaseRoleClient.queryRoleRecommendList(queryRoleRecommendListReqDto).getData();


        queryRoleRecommendListRespDto_1 = queryRoleRecommendListRespDto;

//步骤1: D1-3批量查询就职记录(管理)(公共) - batchQueryInductionRecordCom
        BatchQueryInductionRecordComRespDto batchQueryInductionRecordComRespDto = null;
        if (queryRoleRecommendListRespDto != null) {
            BatchQueryInductionRecordComReqDto batchQueryInductionRecordComReqDto = new BatchQueryInductionRecordComReqDto();
            if (queryRoleRecommendListRespDto != null) {
                batchQueryInductionRecordComReqDto.setOrgInductionRecordList(queryRoleRecommendListRespDto.getRoleList().stream().map(item -> item.getOperationInductionId())
                        .collect(Collectors.toList()));/*list-to-strings*///sourceId:417739_1
            }

            /*D1-3批量查询就职记录(管理)(公共)[5024]   */

            batchQueryInductionRecordComRespDto = fwBaseInductionRecordClient.batchQueryInductionRecordCom(batchQueryInductionRecordComReqDto).getData();


            batchQueryInductionRecordComRespDto_1 = batchQueryInductionRecordComRespDto;
        }

        BffQueryRoleRecommendListRespDto retData = new BffQueryRoleRecommendListRespDto();
        //数据集融合  MoreListToOneSource
        if (queryRoleRecommendListRespDto_1 != null && !CollectionUtil.isEmpty(queryRoleRecommendListRespDto_1.getRoleList())) {
            for (FrameworkSceneRoleDto frameworkSceneRoleDto : queryRoleRecommendListRespDto_1.getRoleList()) {
                BffRoleRecommendDto retElm = new BffRoleRecommendDto();
                if (queryRoleRecommendListRespDto_1 != null) {
                    retElm.setRoleId(frameworkSceneRoleDto.getRoleId());//SimpleFieldAssign//sourceId:113106_2
                    retElm.setRoleCode(frameworkSceneRoleDto.getRoleCode());//SimpleFieldAssign//sourceId:113107_2
                    retElm.setRoleName(frameworkSceneRoleDto.getRoleName());//SimpleFieldAssign//sourceId:113108_2
                    retElm.setRoleLogo(frameworkSceneRoleDto.getRoleLogo());//SimpleFieldAssign//sourceId:113109_2
                    retElm.setRoleType(frameworkSceneRoleDto.getRoleType());//SimpleFieldAssign//sourceId:113110_2
                    retElm.setIsIdentity(frameworkSceneRoleDto.getIsIdentity());//SimpleFieldAssign//sourceId:113111_2
                    retElm.setIsRecommend(frameworkSceneRoleDto.getIsRecommend());//SimpleFieldAssign//sourceId:113112_2
                    retElm.setOperationInductionId(frameworkSceneRoleDto.getOperationInductionId());//SimpleFieldAssign//sourceId:113113_2
                    retElm.setOperateTime(frameworkSceneRoleDto.getOperateTime());//SimpleFieldAssign//sourceId:113118_2
                }
                retData.getRoleRecommendList().add(retElm);
                if (batchQueryInductionRecordComRespDto_1 != null) {
                    for (OrgInductionRecordDto orgInductionRecordDto : batchQueryInductionRecordComRespDto_1.getOrgInductionRecordList()) {
                        if (orgInductionRecordDto.getInductionRecordId().equals(frameworkSceneRoleDto.getOperationInductionId())) {
                            if (batchQueryInductionRecordComRespDto_1 != null) {
                                retElm.setUserId(orgInductionRecordDto.getUserId());//SimpleFieldAssign//sourceId:114946_2
                                retElm.setUserFace(orgInductionRecordDto.getUserFace());//SimpleFieldAssign//sourceId:114947_2
                                retElm.setIdCardName(orgInductionRecordDto.getIdCardName());//SimpleFieldAssign//sourceId:114948_2
                                retElm.setNickName(orgInductionRecordDto.getNickName());//SimpleFieldAssign//sourceId:114949_2
                            }
                        }
                    }
                }

            }
        }//sourceId:407468_1


        return retData;
    }

    /**
     * B1-2查询角色推荐到业务场景列表(管理)[5053]
     * gen by moon at 10/28/2022, 8:54:36 PM
     */
    @Trace(operationName = "B1-2查询角色推荐到业务场景列表(管理)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryRoleRecommendBizSceneListRespDto queryRoleRecommendBizSceneList(BffQueryRoleRecommendBizSceneListReqDto reqDto) {


        QueryRoleRecommendBizSceneListRespDto queryRoleRecommendBizSceneListRespDto_1 = null;
        BatchQueryBizSceneRespDto batchQueryBizSceneRespDto_1 = null;
//步骤0: D1-2查询角色推荐到业务场景列表 - queryRoleRecommendBizSceneList
        QueryRoleRecommendBizSceneListRespDto queryRoleRecommendBizSceneListRespDto = null;
        QueryRoleRecommendBizSceneListReqDto queryRoleRecommendBizSceneListReqDto = new QueryRoleRecommendBizSceneListReqDto();
        if (reqDto != null) {
            queryRoleRecommendBizSceneListReqDto.setRoleId(reqDto.getRoleId());//SimpleFieldAssign//sourceId:407543_1
            queryRoleRecommendBizSceneListReqDto.setIsArchive(reqDto.getIsArchive());//SimpleFieldAssign//sourceId:407544_1
        }

        /*D1-2查询角色推荐到业务场景列表[5039]   */
        Assert.isNull(queryRoleRecommendBizSceneListReqDto.getRoleId(), "B1-2查询角色推荐到业务场景列表(管理)-D1-2查询角色推荐到业务场景列表-推荐的角色ID不能为空", false);
        Assert.isNull(queryRoleRecommendBizSceneListReqDto.getIsArchive(), "B1-2查询角色推荐到业务场景列表(管理)-D1-2查询角色推荐到业务场景列表-是否存档不能为空", false);
        queryRoleRecommendBizSceneListRespDto = fwBaseRoleClient.queryRoleRecommendBizSceneList(queryRoleRecommendBizSceneListReqDto).getData();


        queryRoleRecommendBizSceneListRespDto_1 = queryRoleRecommendBizSceneListRespDto;

//步骤1: D1-1批量查业务场景 - batchQueryBizScene
        BatchQueryBizSceneRespDto batchQueryBizSceneRespDto = null;
        if (queryRoleRecommendBizSceneListRespDto != null) {
            BatchQueryBizSceneReqDto batchQueryBizSceneReqDto = new BatchQueryBizSceneReqDto();
            if (queryRoleRecommendBizSceneListRespDto != null) {
                batchQueryBizSceneReqDto.setBizSceneList(queryRoleRecommendBizSceneListRespDto.getRoleRecommendBizSceneList().stream().map(item -> item.getBizSceneId())
                        .collect(Collectors.toList()));/*list-to-strings*///sourceId:407550_1
            }

            /*D1-1批量查业务场景[861]   */

            batchQueryBizSceneRespDto = fwBaseAppSceneClient.batchQueryBizScene(batchQueryBizSceneReqDto).getData();


            batchQueryBizSceneRespDto_1 = batchQueryBizSceneRespDto;
        }

        BffQueryRoleRecommendBizSceneListRespDto retData = new BffQueryRoleRecommendBizSceneListRespDto();
        //数据集融合  MoreListToOneSource
        if (queryRoleRecommendBizSceneListRespDto_1 != null && !CollectionUtil.isEmpty(queryRoleRecommendBizSceneListRespDto_1.getRoleRecommendBizSceneList())) {
            for (RoleRecommendBizSceneDto roleRecommendBizSceneDto : queryRoleRecommendBizSceneListRespDto_1.getRoleRecommendBizSceneList()) {
                BffRoleRecommendBizSceneDto retElm = new BffRoleRecommendBizSceneDto();
                if (queryRoleRecommendBizSceneListRespDto_1 != null) {
                    retElm.setTopBizSceneRecordId(roleRecommendBizSceneDto.getTopBizSceneRecordId());//SimpleFieldAssign//sourceId:113235_2
                    retElm.setRoleId(roleRecommendBizSceneDto.getRoleId());//SimpleFieldAssign//sourceId:113236_2
                    retElm.setRoleCode(roleRecommendBizSceneDto.getRoleCode());//SimpleFieldAssign//sourceId:113237_2
                    retElm.setBizAppCode(roleRecommendBizSceneDto.getBizAppCode());//SimpleFieldAssign//sourceId:113238_2
                    retElm.setBizSceneId(roleRecommendBizSceneDto.getBizSceneId());//SimpleFieldAssign//sourceId:113239_2
                    retElm.setBizSenceCode(roleRecommendBizSceneDto.getBizSenceCode());//SimpleFieldAssign//sourceId:113240_2
                    retElm.setSubjectLifeCycle(roleRecommendBizSceneDto.getSubjectLifeCycle());//SimpleFieldAssign//sourceId:113241_2
                    retElm.setOperationInductionId(roleRecommendBizSceneDto.getOperationInductionId());//SimpleFieldAssign//sourceId:113242_2
                    retElm.setOperateTime(roleRecommendBizSceneDto.getOperateTime());//SimpleFieldAssign//sourceId:113243_2
                }
                retData.getRoleRecommendBizSceneList().add(retElm);
                if (batchQueryBizSceneRespDto_1 != null) {
                    for (BizSceneDto bizSceneDto : batchQueryBizSceneRespDto_1.getBizSceneList()) {
                        if (bizSceneDto.getBizSceneId().equals(roleRecommendBizSceneDto.getBizSceneId())) {
                            if (batchQueryBizSceneRespDto_1 != null) {
                                retElm.setBizAppId(bizSceneDto.getBizAppId());//SimpleFieldAssign//sourceId:113257_2
                                retElm.setBizAppName(bizSceneDto.getBizAppName());//SimpleFieldAssign//sourceId:113258_2
                                retElm.setBizSceneName(bizSceneDto.getBizSceneName());//SimpleFieldAssign//sourceId:113259_2
                            }
                        }
                    }
                }

            }
        }//sourceId:407548_1


        return retData;
    }

    /**
     * B1-2查询角色未推荐业务场景列表(管理)[5054]
     * gen by moon at 10/28/2022, 8:54:40 PM
     */
    @Trace(operationName = "B1-2查询角色未推荐业务场景列表(管理)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryRoleNoRecommendBizSceneListRespDto queryRoleNoRecommendBizSceneList(BffQueryRoleNoRecommendBizSceneListReqDto reqDto) {


        QueryHostTypeCollectionRemoveExistingDataListRespDto collectionRemoveExistingDataRes_1 = null;
//步骤0: D1-2查询角色未推荐业务场景列表 - queryRoleNoRecommendBizSceneList
        QueryRoleNoRecommendBizSceneListRespDto queryRoleNoRecommendBizSceneListRespDto = null;
        QueryRoleNoRecommendBizSceneListReqDto queryRoleNoRecommendBizSceneListReqDto = new QueryRoleNoRecommendBizSceneListReqDto();
        if (reqDto != null) {
            queryRoleNoRecommendBizSceneListReqDto.setBizAppCode(reqDto.getBizAppCode());//SimpleFieldAssign//sourceId:407581_1
            queryRoleNoRecommendBizSceneListReqDto.setByBizAppId(reqDto.getByBizAppId());//SimpleFieldAssign//sourceId:407582_1
            queryRoleNoRecommendBizSceneListReqDto.setRoleId(reqDto.getRoleId());//SimpleFieldAssign//sourceId:407583_1
        }

        /*D1-2查询角色未推荐业务场景列表[5045]   */
        Assert.isNull(queryRoleNoRecommendBizSceneListReqDto.getBizAppCode(), "B1-2查询角色未推荐业务场景列表(管理)-D1-2查询角色未推荐业务场景列表-业务应用标识不能为空", false);
        Assert.isNull(queryRoleNoRecommendBizSceneListReqDto.getByBizAppId(), "B1-2查询角色未推荐业务场景列表(管理)-D1-2查询角色未推荐业务场景列表-被赋能业务应用ID不能为空", false);
        Assert.isNull(queryRoleNoRecommendBizSceneListReqDto.getRoleId(), "B1-2查询角色未推荐业务场景列表(管理)-D1-2查询角色未推荐业务场景列表-推荐的角色ID不能为空", false);
        queryRoleNoRecommendBizSceneListRespDto = fwBaseRoleClient.queryRoleNoRecommendBizSceneList(queryRoleNoRecommendBizSceneListReqDto).getData();


//步骤1: D查询过滤后可推荐业务场景列表 - queryHostTypeCollectionRemoveExistingDataList
        //ModelCode: collectionRemoveExistingData
        QueryHostTypeCollectionRemoveExistingDataListRespDto collectionRemoveExistingDataRes = null;
        if (queryRoleNoRecommendBizSceneListRespDto != null) {
            QueryHostTypeCollectionRemoveExistingDataListReqDto collectionRemoveExistingDataReq = new QueryHostTypeCollectionRemoveExistingDataListReqDto();
            if (queryRoleNoRecommendBizSceneListRespDto != null && queryRoleNoRecommendBizSceneListRespDto.getBizAppSceneRelList() != null && !CollectionUtil.isEmpty(queryRoleNoRecommendBizSceneListRespDto.getBizAppSceneRelList())) {
                collectionRemoveExistingDataReq.setBizSceneList(queryRoleNoRecommendBizSceneListRespDto.getBizAppSceneRelList().stream().map(item -> BeanUtil.toBean(item, BizSceneDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:407589_1
            }
            if (queryRoleNoRecommendBizSceneListRespDto != null) {
                collectionRemoveExistingDataReq.setHostTypeBizScnList(queryRoleNoRecommendBizSceneListRespDto.getRoleRecommendBizSceneList());//list-field-assign//sourceId:407590_1
            }

            /*D查询过滤后可推荐业务场景列表[1593]  入参两个数据集，通过已存在标识字段匹配，去除第一个数据集中已存在的第二个数据集的数据 */

            collectionRemoveExistingDataRes = nbRole.queryHostTypeCollectionRemoveExistingDataList(collectionRemoveExistingDataReq);


            collectionRemoveExistingDataRes_1 = collectionRemoveExistingDataRes;
        }

        BffQueryRoleNoRecommendBizSceneListRespDto retData = new BffQueryRoleNoRecommendBizSceneListRespDto();
        if (collectionRemoveExistingDataRes_1 != null) {
            retData.setRoleNoRecommendBizSceneList(collectionRemoveExistingDataRes_1.getBizSceneList().stream().map(item -> BeanUtil.toBean(item, BffRoleNoRecommendBizSceneDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:407592_1
        }


        return retData;
    }

    /**
     * B1-2新增角色推荐到业务场景(管理)[5055]
     * gen by moon at 10/28/2022, 8:54:42 PM
     */
    @Trace(operationName = "B1-2新增角色推荐到业务场景(管理)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffAddRoleRecommendBizSceneRespDto addRoleRecommendBizScene(BffAddRoleRecommendBizSceneReqDto reqDto) {


        AddRoleRecommendBizSceneRespDto addRoleRecommendBizSceneRespDto_1 = null;
//步骤0: D1-2新增角色推荐到业务场景 - addRoleRecommendBizScene
        AddRoleRecommendBizSceneRespDto addRoleRecommendBizSceneRespDto = null;
        AddRoleRecommendBizSceneReqDto addRoleRecommendBizSceneReqDto = new AddRoleRecommendBizSceneReqDto();
        if (reqDto != null) {
            addRoleRecommendBizSceneReqDto.setRoleId(reqDto.getRoleId());//SimpleFieldAssign//sourceId:407674_1
            addRoleRecommendBizSceneReqDto.setBizAppCode(reqDto.getBizAppCode());//SimpleFieldAssign//sourceId:407675_1
            addRoleRecommendBizSceneReqDto.setBizSceneId(reqDto.getBizSceneId());//SimpleFieldAssign//sourceId:407676_1
            addRoleRecommendBizSceneReqDto.setBizSenceCode(reqDto.getBizSenceCode());//SimpleFieldAssign//sourceId:407677_1
            addRoleRecommendBizSceneReqDto.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//SimpleFieldAssign//sourceId:407678_1
        }

        /*D1-2新增角色推荐到业务场景[5041]   */
        Assert.isNull(addRoleRecommendBizSceneReqDto.getRoleId(), "B1-2新增角色推荐到业务场景(管理)-D1-2新增角色推荐到业务场景-推荐的角色ID不能为空", false);
        Assert.isNull(addRoleRecommendBizSceneReqDto.getBizAppCode(), "B1-2新增角色推荐到业务场景(管理)-D1-2新增角色推荐到业务场景-业务应用标识不能为空", false);
        Assert.isNull(addRoleRecommendBizSceneReqDto.getBizSceneId(), "B1-2新增角色推荐到业务场景(管理)-D1-2新增角色推荐到业务场景-业务场景ID不能为空", false);
        Assert.isNull(addRoleRecommendBizSceneReqDto.getBizSenceCode(), "B1-2新增角色推荐到业务场景(管理)-D1-2新增角色推荐到业务场景-业务场景编码不能为空", false);
        Assert.isNull(addRoleRecommendBizSceneReqDto.getSubjectLifeCycle(), "B1-2新增角色推荐到业务场景(管理)-D1-2新增角色推荐到业务场景-主体生命周期不能为空", false);
        addRoleRecommendBizSceneRespDto = fwBaseRoleClient.addRoleRecommendBizScene(addRoleRecommendBizSceneReqDto).getData();


        addRoleRecommendBizSceneRespDto_1 = addRoleRecommendBizSceneRespDto;

        BffAddRoleRecommendBizSceneRespDto retData = new BffAddRoleRecommendBizSceneRespDto();
        if (addRoleRecommendBizSceneRespDto_1 != null) {
            retData.setTopBizSceneRecordId(addRoleRecommendBizSceneRespDto_1.getTopBizSceneRecordId());//SimpleFieldAssign//sourceId:407685_1
        }


        return retData;
    }

    /**
     * B1-2删除角色推荐到业务场景(管理)[5056]
     * gen by moon at 10/28/2022, 8:54:45 PM
     */
    @Trace(operationName = "B1-2删除角色推荐到业务场景(管理)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffDeleteRoleRecommendBizSceneRespDto deleteRoleRecommendBizScene(BffDeleteRoleRecommendBizSceneReqDto reqDto) {


        //步骤0: D1-2删除角色推荐到业务场景 - deleteRoleRecommendBizScene
        DeleteRoleRecommendBizSceneRespDto deleteRoleRecommendBizSceneRespDto = null;
        DeleteRoleRecommendBizSceneReqDto deleteRoleRecommendBizSceneReqDto = new DeleteRoleRecommendBizSceneReqDto();
        if (reqDto != null) {
            deleteRoleRecommendBizSceneReqDto.setTopBizSceneRecordId(reqDto.getTopBizSceneRecordId());//SimpleFieldAssign//sourceId:407757_1
        }

        /*D1-2删除角色推荐到业务场景[5042]   */
        Assert.isNull(deleteRoleRecommendBizSceneReqDto.getTopBizSceneRecordId(), "B1-2删除角色推荐到业务场景(管理)-D1-2删除角色推荐到业务场景-推荐角色记录ID不能为空", false);
        deleteRoleRecommendBizSceneRespDto = fwBaseRoleClient.deleteRoleRecommendBizScene(deleteRoleRecommendBizSceneReqDto).getData();


        BffDeleteRoleRecommendBizSceneRespDto retData = new BffDeleteRoleRecommendBizSceneRespDto();


        return retData;
    }

    /**
     * B1-2存档角色推荐到业务场景(管理)[5060]
     * gen by moon at 10/28/2022, 8:54:47 PM
     */
    @Trace(operationName = "B1-2存档角色推荐到业务场景(管理)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffArchiveRoleRecommendBizSceneRespDto archiveRoleRecommendBizScene(BffArchiveRoleRecommendBizSceneReqDto reqDto) {


        //步骤0: D1-2存档角色推荐到业务场景 - archiveRoleRecommendBizScene
        ArchiveRoleRecommendBizSceneRespDto archiveRoleRecommendBizSceneRespDto = null;
        ArchiveRoleRecommendBizSceneReqDto archiveRoleRecommendBizSceneReqDto = new ArchiveRoleRecommendBizSceneReqDto();
        if (reqDto != null) {
            archiveRoleRecommendBizSceneReqDto.setTopBizSceneRecordId(reqDto.getTopBizSceneRecordId());//SimpleFieldAssign//sourceId:408024_1
            archiveRoleRecommendBizSceneReqDto.setRoleId(reqDto.getRoleId());//SimpleFieldAssign//sourceId:408025_1
        }

        /*D1-2存档角色推荐到业务场景[5057]   */
        Assert.isNull(archiveRoleRecommendBizSceneReqDto.getTopBizSceneRecordId(), "B1-2存档角色推荐到业务场景(管理)-D1-2存档角色推荐到业务场景-推荐角色记录ID不能为空", false);
        Assert.isNull(archiveRoleRecommendBizSceneReqDto.getRoleId(), "B1-2存档角色推荐到业务场景(管理)-D1-2存档角色推荐到业务场景-推荐的角色ID不能为空", false);
        archiveRoleRecommendBizSceneRespDto = fwBaseRoleClient.archiveRoleRecommendBizScene(archiveRoleRecommendBizSceneReqDto).getData();


        BffArchiveRoleRecommendBizSceneRespDto retData = new BffArchiveRoleRecommendBizSceneRespDto();


        return retData;
    }

    /**
     * B1-2发布角色推荐到业务场景(管理)[5061]
     * gen by moon at 10/28/2022, 8:54:50 PM
     */
    @Trace(operationName = "B1-2发布角色推荐到业务场景(管理)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffReleaseRoleRecommendBizSceneRespDto releaseRoleRecommendBizScene(BffReleaseRoleRecommendBizSceneReqDto reqDto) {


        //步骤0: D1-2发布角色推荐到业务场景 - releaseRoleRecommendBizScene
        ReleaseRoleRecommendBizSceneRespDto releaseRoleRecommendBizSceneRespDto = null;
        ReleaseRoleRecommendBizSceneReqDto releaseRoleRecommendBizSceneReqDto = new ReleaseRoleRecommendBizSceneReqDto();
        if (reqDto != null) {
            releaseRoleRecommendBizSceneReqDto.setTopBizSceneRecordId(reqDto.getTopBizSceneRecordId());//SimpleFieldAssign//sourceId:408172_1
        }

        /*D1-2发布角色推荐到业务场景[5044]   */
        Assert.isNull(releaseRoleRecommendBizSceneReqDto.getTopBizSceneRecordId(), "B1-2发布角色推荐到业务场景(管理)-D1-2发布角色推荐到业务场景-推荐角色记录ID不能为空", false);
        releaseRoleRecommendBizSceneRespDto = fwBaseRoleClient.releaseRoleRecommendBizScene(releaseRoleRecommendBizSceneReqDto).getData();


        BffReleaseRoleRecommendBizSceneRespDto retData = new BffReleaseRoleRecommendBizSceneRespDto();


        return retData;
    }
    //
}
